<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Document</title>
</head>

<body>
  <div id="app">
    <!-- 双向数据绑定 靠的是表单 -->
    <input type="text" v-model="message.a" />
    <button @click="init">按钮</button>
    <div>{{ message.a }}</div>
    {{ message.b.ss }}
    {{ b }}
  </div>
</body>

</html>
<script src="observer.js"></script>
<script src="watcher.js"></script>
<script src="compile.js"></script>
<script src="dep.js"></script>
<script src="mvvm.js"></script>
<script>
  let vm = new MVVM({
    el: "#app",
    data: {
      message: {
        a: "wlf", b: {
          ss: 'xxx'
        }
      },
      b: "biubiubiu"
    },
    methods: {
      init() {
        console.log(this.message.a)
      }
    },
    watch: {
      b(newVal, oldVal) {
        console.log('newVal:' + newVal);
        console.log('oldVal:' + oldVal);
      }
    },
    created() {
      this.b = 'ooooop'
    },
    mounted() {
      console.log(this.b)
    }
  });
</script>